﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace AngelPerez.Taringa.PostEdit {
	class TransPanel : Panel {
		Timer Wriggler = new Timer();
		Pen ThePen = Pens.Transparent;

		public TransPanel() {
			Wriggler.Tick += new EventHandler(TickHandler);
			this.Wriggler.Interval = 500;
			this.Wriggler.Enabled = true;
		}

		public TransPanel(Pen pen) {
			ThePen = pen;
		}

		protected void TickHandler(object sender, EventArgs e) {
			this.InvalidateEx();
		}

		protected override CreateParams CreateParams {
			get {
				CreateParams cp = base.CreateParams;
				cp.ExStyle |= 0x00000020;
				return cp;
			}
		}

		protected void InvalidateEx() {
			if (Parent == null)
				return;

			Rectangle rc = new Rectangle(this.Location, this.Size);
			Parent.Invalidate(rc, true);
		}

		protected override void OnPaint(PaintEventArgs pevent) {
			pevent.Graphics.DrawRectangle(ThePen, 0, 0, this.Width - 1, this.Height - 1);
		}

		protected override void OnPaintBackground(PaintEventArgs e) {
			
		}
	}
}
